package com.example.english.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.example.english.R;
import com.example.english.adapter.TabAdapter;
import com.example.english.db.Tab1Bean;

import java.util.ArrayList;
import java.util.List;

public class Tab1Fragment extends Fragment {

    private RecyclerView recyclerView;
    private TabAdapter adapter;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_tab1,container,false);
        return view;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        recyclerView = view.findViewById(R.id.recyclerView);
        adapter = new TabAdapter();
        recyclerView.setAdapter(adapter);
        recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));

        adapter.setList(getList());

    }


    public List<Tab1Bean> getList(){
        List<Tab1Bean> list = new ArrayList<>();
        Tab1Bean t1 = new Tab1Bean();
        t1.setTitle("钉题库大学英语B，3000大纲词汇领学");
        t1.setName("张老师");
        t1.setDes("在家学英语随时随地地放心学，高频互动开口快速提升口语能力");
        t1.setImg(R.drawable.p1);
        t1.setUrl("android.resource://com.example.english/"+R.raw.v1);

        Tab1Bean t2 = new Tab1Bean();
        t2.setTitle("大学英语词汇");
        t2.setName("李老师");
        t2.setDes("英语作文常用万能句子、句型及模板");
        t2.setImg(R.drawable.p2);
        t2.setUrl("android.resource://com.example.english/"+R.raw.v2);

        Tab1Bean t3 = new Tab1Bean();
        t3.setTitle("大学英语B-单词领进班");
        t3.setName("王老师");
        t3.setDes("今天给大家整理的是励志的英文文案,每句都很治愈,很高级,又不乏触及心灵深处的力度,一起来看看叭!");
        t3.setImg(R.drawable.p3);
        t3.setUrl("android.resource://com.example.english/"+R.raw.v3);

        list.add(t1);
        list.add(t2);
        list.add(t3);
        return list;
    }
}
